//
//  Ticket.m
//  NiuBanJin
//
//  Created by Billy on 15/10/14.
//  Copyright © 2015年 zzjr. All rights reserved.
//

#import "Ticket.h"

@implementation Ticket

- (instancetype)initWithAttributes:(NSDictionary *)attributesDic  {
    
    self = [super init];
    
    if (self) {
        
        if ([attributesDic[@"colorType"] integerValue] == 1) {
            
            self.ticketType = TicketTypeBlue;
        }else if([attributesDic[@"colorType"] integerValue] == 2) {
            
            self.ticketType = TicketTypeYellow;
        }else if([attributesDic[@"colorType"] integerValue] == 3) {
            
            self.ticketType = TicketTypeOrange;
        }else if([attributesDic[@"colorType"] integerValue] == 4) {
            
            self.ticketType = TicketTypeRed;
        } else if ([attributesDic[@"colorType"] integerValue] > 4){ //不是已知的颜色统一弄成橙色暂时
            
            self.ticketType = TicketTypeOrange;
        }
        
        self.ticket_expiredDate = [attributesDic objectForKey:@"expiredDate"];
        self.ticket_number_id = [attributesDic objectForKey:@"id"];
        self.ticket_number_value = [attributesDic objectForKey:@"rate"];
        self.ticket_number_period = [attributesDic objectForKey:@"period"];
        self.ticket_couponStatus = [attributesDic objectForKey:@"couponStatus"]; //状态
    }
    
    return self;
}

- (instancetype)initExchangeTicketWithAttributes:(NSDictionary *)attributesDic  {
    
    if (self = [super init]) {
        
        if ([attributesDic[@"colorType"] integerValue] == 1) { //颜色
            
            self.ticketType = TicketTypeBlue;
        }else if([attributesDic[@"colorType"] integerValue] == 2){
            
            self.ticketType = TicketTypeYellow;
        }else if([attributesDic[@"colorType"] integerValue] == 3){
            
            self.ticketType = TicketTypeOrange;
        }else if([attributesDic[@"colorType"] integerValue] == 4) {
            
            self.ticketType = TicketTypeRed;
        }else if ([attributesDic[@"colorType"] integerValue] > 4){ //不是已知的颜色统一弄成橙色暂时
            
            self.ticketType = TicketTypeOrange;
        }
        
        self.ticket_number_id = [attributesDic objectForKey:@"id"];
        self.ticket_exchangeScore = [attributesDic objectForKey:@"score"]; //多少分换一个
        self.ticket_number_period = [attributesDic objectForKey:@"couponDay"]; //期限
        self.ticket_number_value = [attributesDic objectForKey:@"rate"];//利率
        self.ticket_brief = [attributesDic objectForKey:@"brief"];
    }
    
    return self;
}

@end
